package com.j2ee.JDKProxy.salary;

import java.lang.reflect.Proxy;

import org.junit.Test;

public class SalaryManagerTest {
	
	@Test
	public void testSalaryManager() {
		Object target = new SalaryManagerImpl() ;
		Logger logger = new Logger() ;
		Security security = new Security() ;
		privilege privilege = new privilege() ;
		privilege.setAccess("admin") ;
		//创建拦截器对象
		SalaryInterceptor interceptor = new SalaryInterceptor(target, logger, security, privilege) ;
		//创建目标类代理对象
		SalaryManager salaryManager = (SalaryManager) Proxy.newProxyInstance(
				target.getClass().getClassLoader(), target.getClass().getInterfaces(), interceptor) ;
		salaryManager.showSalary() ;
	}
}
